<!-- application/index/view/index/index.html -->

<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>用户登录</title>
    <link rel="stylesheet" href="/static/plugs/layui/css/layui.css">
    <link rel="stylesheet" href="/static/zhiniao/css/index.css">
</head>
<body>
<div class="layui-container">
    <div class="layui-layout layui-layout-admin ">
    <!-- 导航栏 -->
    {include file="index/header"}
    <div class="addlunwen-body">
        <div class="layui-row" style="margin-top: 100px;">
            <div class="layui-col-md-4">
                <div class="login-title">提交论文编写任务</div>
                <form class="layui-form" id="lunwen-form" lay-filter="lunwen-form" action="addlunwen" method="post" style="margin-top: 100px;">
                    <div class="layui-form-item">
                        <label class="layui-form-label">论文标题</label>
                        <!-- <div class="lunwen-input-block"> -->
                        <div class="layui-input-block">
                            <input type="text" id="title" name="title" required lay-verify="required" placeholder="输入完整的论文标题，以获得更好的生成效果" autocomplete="off" class="layui-input" style="width: 100%;">
                            <p class="help-block">* 知鸟AI保护你的论文隐私安全，采用腾讯云COS安全储存，SSL传输加密，绝不泄漏论文的任何信息</p>
                        </div>
                    </div>
                    

                    <div class="layui-form-item">
                        <label class="layui-form-label">论文层次</label>
                        <div class="layui-input-block">
                            <input type="radio" id="cengci" name="cengci" value="1" title="专科（消耗200知鸟券）">
                            <input type="radio" id="cengci" name="cengci" value="2" title="本科（消耗400知鸟券）" checked>
                            <br>
                            <p class="help-block">专科论文查重率 <b>不保证</b> 低于20%，<b>消耗200知鸟券</b></p>
                            <p class="help-block">本科论文查重率 <b>保证</b> 低于20%，<b>消耗400知鸟券</b></p>
                            <p class="help-block">当前可用知鸟券:{$balance}</p>
                        </div>
                    </div>
                    
                    <div class="layui-form-item" style="margin-top: 100px; text-align: center;">
                        <div class="lunwen-input-block">
                            <button class="el-button-primy" style="width: 20%; margin: 0 5% 0 25%;" lay-submit lay-filter="submit">提交论文</button>
                            <button class="el-button-primy-01" style="width: 20%; margin: 0 25% 0 5%;">查看结果</button>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>


</div>
<script src="/static/plugs/layui/layui.js"></script>
<script src="/static/plugs/jquery/jquery.min.js"></script>
<script>


$(function(){
    layui.use(['form'], function(){
        var form = layui.form;

        var balance = {$balance};

        form.on('submit(lunwen-form)', function(data) {
            // 弹出提示框
            var cengci_arr = {
                1: {
                    name: '专科',
                    cost: 200
                },
                2: {
                    name: '本科',
                    cost: 400
                }
            };
            var title = $('#title').val();
            var cengci = $('input[name=cengci]:checked').val();
            console.log(title);
            console.log(cengci);

            if(balance < cengci_arr[cengci]['cost']){
                layer.confirm("当前可用知鸟券不足，请先充值。", function(index) {
                    layer.close(index);
                    window.location = "/index/index/cost";
                }, function(index) {
                    layer.close(index);
                });
                return false;
            }
    
            // console.log(cengci);
            // console.log(title);
            // return false;
            var result = layer.confirm('<p>请确认任务信息:</p><p>层次：<b>'+cengci_arr[cengci]['name']+'</b></p>标题：<b>'+ title +'</b></p>消耗知鸟券：<b>' + cengci_arr[cengci]['cost'] + '</b></p>', function(index) {
                // 用户点击了确认，提交表单
                layer.close(index);
                // TODO: 提交表单的代码
                $("#lunwen-form").submit();
                return true;
            }, function(index) {
                layer.close(index);
                // 用户点击了取消，不提交表单
                return false;
            });
            // 阻止表单的自动提交
            return false;
        });
    });
});

</script>
</body>
</html>